<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>垂直居中布局解决方案3-flex+align-items</title>
  <style>
    /* 
    display:inline/block/inline-block/none/table/
    display:box/flexbox/flex

    弹性盒模型  box  = flexbox =  flex

    新布局: grid + colunms + shapes

    display:box  盒子模型  

    px + % + em + rem + vw + vh + vmin+ vmax  + pt.....

    postcss
    */

    * {
      margin: 0;
      padding: 0;
    }
    #parent{
       width: 500px;
       height: 500px;
       background-color: red;
       /*  display: flex; 子容器默认是水平排列 */
       display: flex;
       /* 水平居中 */
       justify-content: center;
       /* 垂直居中 */
       align-items: center;
     }
     .child{
       width: 100px;
       height:100px;margin:5px;
       background-color: green;
     }
        
  </style>
</head>

<body>
  <!-- 定义父级元素 -->
  <div id="parent">
    <!-- 定义子级元素 -->
    <div class="child"></div>
    <div class="child"></div>
    <div class="child"></div>
  </div>
</body>

</html>